Skip to main content

Compare Documents

Visually compare the differences between 2 files.

If you want to visually compare the differences between 2 files, TFTPDF can achieve this by comparing 2 files and generating a new document with the differences.

TFTPDF using pixel-by-pixel comparison in wich an output image will be generated from the differences.

Functions

compare

Add a JSON annotation on the PDF. The command parse the Json with the className and draw the annotation on the correct page.

ParamTypeDescription
url1stringThe base document
url2stringThe second document to compare with base
qualitystringThe quality of the comparison
commonColorstringThe desired color to highlight the comparison

Available quality options:

  • low: 65% quality
  • medium: 85% quality
  • high: 125% quality

Example

TFTPDFGadget.callCommand({
name: 'compare',
args: {
url1: 'https://mediaserver.com/yourfile.pdf',
url2: 'https://mediaserver.com/yourfile.pdf',
quality: 'medium',
commonColor: 'green',
},
callback: myfunc,
});
Avoid CORS error

Please see this guide to setup your application in order to avoid CORS error.

compareWith

Compare the current pdf with another one.

ParamTypeDescription
urlstringThe document you want to compare with
qualitystringThe quality of the comparison
commonColorstringThe desired color to highlight the comparison

Available quality options:

  • low: 65% quality
  • medium: 85% quality
  • high: 125% quality

Example

TFTPDFGadget.callCommand({
name: 'compareWith',
args: {
url: 'https://mediaserver.com/yourfile.pdf',
quality: 'medium',
commonColor: 'green',
},
callback: myfunc,
});
Avoid CORS error

Please see this guide to setup your application in order to avoid CORS error.

resetCompare

Reset the actual comparison process and reset the viewer.

Example

TFTPDFGadget.callCommand({
name: 'resetCompare',
callback: myfunc,
});